<!doctype html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
	<th:block th:include="/A0723/include :: header('修改密码')"/>
</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">修改密码</h1>
		</header>
		<div class="mui-content">
			<div class="forget_from">
<!--				<div class="mui-input-row">-->
<!--					<label>旧密码：</label> 设置数字+字母6位密码-->
<!--					<input type="text" placeholder="请输入旧密码">-->
<!--				</div>-->
				<div class="mui-input-row">
					<label>新密码：</label>
					<input type="password" id="password" placeholder="请输入新密码">
				</div>
				<div class="mui-input-row">
					<label>确认密码：</label>
					<input type="password" id="checkPassword" placeholder="请再次输入新密码">
				</div>
			</div>
			<button type="button" onclick="forget()" class="mui-btn mui-btn-blue mui-btn-block mui_btn">确定修改</button>
		</div>
		<th:block th:include="/A0723/include :: footer"/>
		<script type="text/javascript">
			let data = {}
			//验证
			function validateForget() {
				let password = $("#password").val();
				if (password == null || password === '') {
					mui.toast('请输入密码', {duration: 'long', type: 'div'})
					return
				}
				let checkPassword = $("#checkPassword").val();
				if (checkPassword == null || checkPassword === '') {
					mui.toast('请输入确认密码', {duration: 'long', type: 'div'})
					return
				}
				if (password !== checkPassword) {
					mui.toast('确认密码与密码不一致', {duration: 'long', type: 'div'})
					return
				}
				data.password = password;
				data.checkPassword = checkPassword;
				return true;
			}

			//重置密码
			function forget() {
				if (validateForget()) {
					mui.ajax(ctx+'front/personal/editPwd', {
						data: data,
						dataType: 'json',//服务器返回json格式数据
						type: 'post',//HTTP请求类型
						timeout: 10000,//超时时间设置为10秒；
						headers: {'Content-Type': 'application/json'},
						success: function (res) {
							//服务器返回响应，根据响应结果，分析是否登录成功；
							mui.toast(res.msg, {duration: 'long', type: 'div'})
						},
						error: function (xhr, type, errorThrown) {
							//异常处理；
							console.log(type);
						}
					});
				}
			}

		</script>
	</body>

</html>
